package com.zy.web.demo.duoxiancheng.demo38;

import java.util.concurrent.Semaphore;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/10/15 10:45
 */
public class Service38 {

    private Semaphore semaphore = new Semaphore(2);

    public void testMethod(){
        try {
            semaphore.acquire();
            System.out.println(Thread.currentThread().getName()+"  begin time="+System.currentTimeMillis());
            Thread.sleep(5000);
            System.out.println(Thread.currentThread().getName()+"  end time="+System.currentTimeMillis());
            semaphore.release();
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }

}
